<template>
  <div class="common-table">
    <el-table :data="tableData" height="90%" stripe v-loading="config.loading">
      <!-- 序号 -->
      <el-table-column label="序号" width="85">
        <template v-slot:default="scope">
          <span style="margin-left: 10px">{{
            (config.page - 1) * config.limit + scope.$index + 1
          }}</span>
          <!-- <span style="margin-left: 10px">{{scope.$index + 1}} </span> -->
        </template>
      </el-table-column>
      <!-- tabledata里的列 -->
      <el-table-column
        show-overflow-tooltip
        v-for="item in tableLabel"
        :key="item.field"
        :label="item.label"
        :width="item.width ? item.width : 125"
      >
        <template #default="scope">
          <span style="margin-left: 10px">{{ scope.row[item.field] }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="180">
        <template #default="scope">
          <el-popover
            placement="top-start"
            :width="200"
            trigger="hover"
            content="点击按钮修改客户信息"
          >
            <template  #reference>
              <el-button size="small" @click="handleEdit(scope.row)"
                >编辑</el-button
              >
            </template>
          </el-popover>
          <el-popover
            placement="top-start"
            :width="200"
            trigger="hover"
            content="点击按钮删除客户"
          >
            <template  #reference>
          <el-button size="small" type="danger" @click="handleDelete(scope.row)"
            >删除</el-button
          >
          </template>
          </el-popover>
        </template>
      </el-table-column>
    </el-table>
    <!-- 页码 -->
    <!-- <el-pagination class="pager" layout="prev, pager, next" :total="config.total" v-model:current-page="config.page"
            @current-change="changePage" :page-size="config.limit">
        </el-pagination> -->
    <!-- <el-pagination
      :hide-on-single-page=false
      :total="config.total"
      layout="prev, pager, next"
    /> -->
  </div>
</template>

<script>
export default {
  props: {
    tableData: Array,
    tableLabel: Array,
    config: Object,
  },
  methods: {
    handleEdit(row) {
      console.log("edit");
      this.$emit("edit", row);
    },
    handleDelete(row) {
      this.$emit("del", row);
    },
    changePage(page) {
      this.$emit("changePage", page);
    },
  },
};
</script>

<style lang="scss" scoped>
.common-table {
  height: calc(100% - 62px);
  background-color: #fff;
  //   position: relative;
  //   .pager {
  //     position: absolute;
  //     bottom: 0;
  //     right: 20px;
  //   }
}
</style>
